﻿using System.Runtime.Remoting.Contexts;
using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Build;
using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
using UnityEngine.AddressableAssets;

namespace zframe.editor.addressable
{
    public class AdressableBuildToos
    {
        [MenuItem("zframe/addressable/updateBuild")]
        static void UpdateBuild()
        {
            /*
            AddressableAssetProfileSettings profileSettings = AddressableAssetSettingsDefaultObject.Settings.profileSettings;
            string profileId = profileSettings.GetProfileId("remote");
            
            AddressableAssetSettingsDefaultObject.Settings.activeProfileId = profileId;
            */
            string contentPath = ContentUpdateScript.GetContentStateDataPath(false);
            //Debug.Log("AdressableBuildToos profileId=" + profileId+ ",contentPath="+ contentPath);
            
            //AddressablesContentState state = ContentUpdateScript.LoadContentState(contentPath);
            if (!string.IsNullOrEmpty(contentPath))
            {
                ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, contentPath);
            }


        }

        [MenuItem("zframe/addressable/defaultBuild")]
        static void DefaultBuild()
        {
            AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilderIndex = 0;
            AddressableAssetSettings.BuildPlayerContent();

        }

    }
}
